package com.example.ymm.modules1.service.impl.user;

import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ymm.base.BaseServiceImpl;
import com.example.ymm.model.TableList;
import com.example.ymm.model.YmPageDto;
import com.example.ymm.modules1.entity.my.user.OfficeScoreSetting;
import com.example.ymm.modules1.mapper.my.user.OfficeScoreSettingMapper;
import com.example.ymm.modules1.query.OfficeScoreSettingQueryCriteria;
import com.example.ymm.modules1.service.user.OfficeScoreSettingService;
import com.example.ymm.util.QueryHelpPlus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DSTransactional
@Slf4j
public class OfficeScoreSettingServiceImpl extends BaseServiceImpl<OfficeScoreSettingMapper, OfficeScoreSetting> implements OfficeScoreSettingService {

    @Override
    public TableList<OfficeScoreSetting> list(OfficeScoreSettingQueryCriteria criteria, YmPageDto pageDto) {
        IPage<OfficeScoreSetting> page = new Page<OfficeScoreSetting>(pageDto.getPage(),pageDto.getPageSize());
        QueryWrapper predicate = QueryHelpPlus.getPredicate(OfficeScoreSetting.class, criteria);
//        predicate.orderByDesc("create_time");
        baseMapper.selectPage(page, predicate);
        TableList<OfficeScoreSetting> tableList=new TableList(page);
        return tableList;
    }

    public List<OfficeScoreSetting> queryAll(OfficeScoreSettingQueryCriteria criteria) {
        List<OfficeScoreSetting> result =baseMapper.selectList(QueryHelpPlus.getPredicate(OfficeScoreSetting.class, criteria));
        return result;
    }
}
